#!/usr/bin/env python
# -*- encoding: utf-8 -*-

"""
@File : features.py
@Author : Braylon1002
@Version : 1.0
@Contact : S.Braylon1002@gmail.com
Desc : None
"""

from collections import OrderedDict

class Features(object):
    def __init__(self,
                 number_feat,
                 category_feat,
                 sequence_feat):
        self.number_feat = number_feat
        self.category_feat = category_feat
        self.sequence_feat = sequence_feat

    def fit(self, dataframe):
        for feature in (
            self.number_feat +
            self.category_feat +
            self.sequence_feat
        ):
            if feature.column_flow:
                feature.column_flow.fit(dataframe[feature.name].values)

        return self

    def transform(self, dataframe):
        transformed_x = OrderedDict()

        for feature in (
            self.number_feat +
            self.category_feat +
            self.sequence_feat
        ):
            if feature.column_flow:
                transformed_x[feature.name] = feature.column_flow.transform(
                    dataframe[feature.name].values
                )
            else:
                transformed_x[feature.name] = dataframe[feature.name].values

        return transformed_x

    def number_feat_names(self):
        return [feature.name for feature in self.number_feat]
    def category_feat_names(self):
        return [feature.name for feature in self.category_feat]
    def sequence_feat_names(self):
        return [feature.name for feature in self.sequence_feat]